/*_____________________________________________________________________________
||
|| STM32 Baremetal Driver: RCC
||
|| Jinfeng Zhuang, 2024.W18
||
|| Additional Feature: SWIP wrapper
||_____________________________________________________________________________
*/

typedef volatile unsigned int VU32;

typedef struct
{
  VU32 CR;
  VU32 CFGR;
  VU32 CIR;
  VU32 APB2RSTR;
  VU32 APB1RSTR;
  VU32 AHBENR;
  VU32 APB2ENR;
  VU32 APB1ENR;
  VU32 BDCR;
  VU32 CSR;
} RCC_TypeDef;

static void rcc_enable(U32 base, U32 ip, U32 enable)
{
    RCC_TypeDef *RCC = (RCC_TypeDef*)base;

    if (enable)
    {
        RCC->APB2ENR |= 1 << 0; // RCC->AHBENR // APB1ENR
    }
    else
    {
        RCC->APB2ENR &= ~(1 << 0);
    }
}

// Unit: Hz
static U32 rcc_clock_get(U32 base, U32 ip)
{
    
}

/*_____________________________________________________________________________
||
|| Wrapper of SWIP
||
|| Include Port related macros.
|| Self compile code, if user want use it, redefine the macros.
||
*/

#ifndef RCC_BASE
#define RCC_BASE (0x0)
#endif

U32 event_handler_soc_rcc(U32 ip, U32 cmd, U32 param1, U32 param2)
{
    
}